import { createRoot } from 'react-dom/client'
import Loading from './loading'
import './index.scss'
let count = 0
export function showLoading() {
  if (count === 0) {
    const loading = document.createElement('div')
    loading.setAttribute('id', 'loading')
    document.body.appendChild(loading)
    createRoot(loading).render(<Loading />)
  }
  count++
}

export function hideLoading() {
  count--
  if (count === 0) {
    const loading = document.getElementById('loading') as HTMLDivElement
    document.body.removeChild(loading)
  }
}
